package ca.etsmtl.log730.projet.view.files;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.swing.table.AbstractTableModel;

import ca.etsmtl.log730.projet.model.RessourceObject;
import ca.etsmtl.log730.projet.model.workspace.TextObject;

public class ObjectTableModel extends AbstractTableModel {
	
	@Override
	public String getColumnName(int column) {
		if(column == 0) return "ID";
		else if(column == 1) return "NAME";
		else if(column == 2) return "DETAILS";
		else if(column == 3) return "SIZE";
		
		return "";
	}
	public Map<UUID, TextObject> objects = new HashMap<UUID, TextObject>();

	public Map<UUID, TextObject> getObjects() {
		return objects;
	}
	public void setObjects(Map<UUID, TextObject> objects) {
		this.objects = objects;
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ObjectTableModel() {
		super();
	}
	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public int getRowCount() {
		return objects.size();
	}

	@Override
	public Object getValueAt(int y, int x) {
		ArrayList<UUID> listUID = new ArrayList<UUID>(objects.keySet());
		UUID ii = listUID.get(y);
		if(x == 0) return ii;
		if(x == 1) return objects.get(ii).getName();
		if(x == 2) return objects.get(ii).getLockInfo().toString();
		if(x == 3) return objects.get(ii).getData().length();
		return "";		
	}


}
